﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ETFK
{
    /// <summary>
    /// 这个类定义了自动测试应返回的结果
    /// </summary>
    public class CheckResult
    {
        /// <summary>
        /// 结果消息
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 结果ID
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// 私有的构造函数
        /// </summary>
        /// <param name="id">结果ID</param>
        /// <param name="Message">结果消息</param>
        private CheckResult(int id , string Message)
        {
            this.ID = id;
            this.Message = Message;
        }

        /// <summary>
        /// 重载Equals方法，判断对象是否相等
        /// </summary>
        /// <param name="obj">要判断的对象</param>
        /// <returns>一致返回True，否则返回False</returns>
        public override bool Equals(object obj)
        {
            CheckResult cr = obj as CheckResult;

            if (cr.ID == this.ID)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 获取该对象的哈希值
        /// </summary>
        /// <returns>返回哈希值</returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        /// <summary>
        /// 返回运行错误结果
        /// </summary>
        public static CheckResult RunError
        {
            get
            {
                return new CheckResult(-1, "运行错误！！！");
            }
        }

        /// <summary>
        /// 返回返回测试失败果
        /// </summary>
        public static CheckResult RunNG
        {
            get
            {
                return new CheckResult(0, "测试失败！！！");
            }
        }

        /// <summary>
        /// 返回测试通过结果
        /// </summary>
        public static CheckResult RunOK
        {
            get
            {
                return new CheckResult(1, "测试通过！！！");
            }
        }

        /// <summary>
        /// 返回错误结果
        /// </summary>
        public static CheckResult NG
        {
            get
            {
                return new CheckResult(2, "失败！");
            }
        }

        /// <summary>
        /// 返回成功结果
        /// </summary>
        public static CheckResult OK
        {
            get
            {
                return new CheckResult(3, "成功！");
            }
        }

        /// <summary>
        /// 返回用户自定义结果
        /// </summary>
        public static CheckResult UserResult(string Message)
        {
            return new CheckResult(999, Message);
        }
        
    }
}
